﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSNPro.Base;
using TSNPro.Device;

namespace TSNPro.OperationControl.Command
{
    public abstract class BaseCommand : BaseItem
    {
        public BaseCommand()
        {

        }

        public virtual void Execute()
        {

        }

        public override void SetConfig(JObject obj)
        {
            base.SetConfig(obj);
            List<BaseDevice> devices = DeviceManager.GetInstance().GetItems<BaseDevice>(obj["Device"].ToArray().OfType<string>().ToList());
            SetDevices(devices);
        }

        public virtual List<BaseCommand> GetSubCommands()
        {
            return new List<BaseCommand>();
        }

        public virtual int GetWeight()
        {
            return _other["Weight"].ToObject<int>();
        }

        List<BaseDevice> _allDevices;
        protected virtual void SetDevices(List<BaseDevice> devices)
        {
            _allDevices = devices;
        }
    }
}
